package com.zh.view.pane

import androidx.compose.foundation.layout.Column
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Clear
import androidx.compose.material.icons.filled.ClearAll
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import com.zh.view.component.FileTaskTable
import com.zh.view.component.RowAction
import com.zh.view.component.TopBar
import com.zh.view.data.ReceiveTaskStore


@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun TaskReceiveScene() {
    var taskList = remember { ReceiveTaskStore.taskList }

    Column {
        TopBar("文件接收",actions = { // 添加右侧操作按钮
            IconButton(onClick = { ReceiveTaskStore.removeAll()}) {
                Icon(
                    imageVector = Icons.Default.ClearAll,
                    contentDescription = "清除全部",
                    tint = MaterialTheme.colorScheme.onSurface
                )
            }
        })

        FileTaskTable(
            data = taskList,
            actions = listOf(
                RowAction(
                    icon = Icons.Default.Clear,
                    contentDescription = "清除",
                    tint = Color.Red,
                    onClick = { ReceiveTaskStore.removeItem(it) }
                )
            )
        )
    }
}
